package com.szyjjk.util;

import java.util.UUID;

import javax.servlet.http.HttpServletRequest;

/**
 * 获取32位随机id
 *
 * @author Administrator
 */
public class UUIDUtils {

    /**
     * 生成32位随机码
     *
     * @return
     */
    public static String getUUID() {
        return UUID.randomUUID().toString().replaceAll("-", "");
    }

    public static String getIpAddress(HttpServletRequest request) {
        String ip = request.getHeader("x-forwarded-for");
        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
            ip = request.getHeader("Proxy-Client-IP");
        }
        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
            ip = request.getHeader("WL-Proxy-Client-IP");
        }
        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
            ip = request.getHeader("HTTP_CLIENT_IP");
        }
        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
            ip = request.getHeader("HTTP_X_FORWARDED_FOR");
        }
        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
            ip = request.getRemoteAddr();
        }
        return ip;
    }
    
    public static String gethardWareData(String str) {
        String pre = "";
        switch (str) {
            case "总氮":
                pre = "总氮浓度";
                break;
            case "总磷":
                pre = "总磷浓度";
                break;
            case "氨氮":
                pre = "氨氮浓度";
                break;
             case "TotP":
                pre = "TP_ppm";
                break;
            case "TotN":
                pre = "TN_ppm";
                break;
            case "浑浊度":
                pre = "浊度";
                break;
            case "叶绿素a":
                pre = "叶绿素";
                break;
            case "温度":
                pre = "空气温度";
                break;
            case "溶解氧":
                pre = "溶解氧";
                break;
            case "盐度":
                pre = "盐度";
                break;
            case "悬浮颗粒":
                pre = "溶解性固体";
                break;
            case "NH4":
                pre = "NH3_ppm";
                break;
            default:
                pre = str;
                break;
        }
        return pre;
    }






}
